package com.neu;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.neu.util.DateConverter;
import com.neu.util.LoginCheckInteceptor;

@SpringBootConfiguration
@MapperScan("com.neu.mapper")
public class AppConfig  implements WebMvcConfigurer{
	
	@Override
	public void addFormatters(FormatterRegistry registry) {
	
		
		DateConverter d= new DateConverter();
		registry.addConverter(d);
		
			}
	
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**")//设置所有处理器都可以的跨域访问
					.allowedOrigins("*")//支持哪些域对处理器访问
					.allowedMethods("*")//支持哪些请求方法（post，get）
					.allowCredentials(true);//支持证书
		
	
	}
	
//	 @Override
//	public void addInterceptors(InterceptorRegistry registry) {
//		 registry.addInterceptor(new LoginCheckInteceptor())
//		 //拦截哪些请求
//		 .addPathPatterns("/**")
//		 //排除哪些请求
//		 .excludePathPatterns("/users/login");
//	}
	
}
